<template>
  <div class="lcdp_axe_main" v-show="alreadyLoad">
    <div class="lcdp_axe jxd_ins_elBaseWebPage jxd_additional DfxtLrsj hussar_0"></div>
  </div>
</template>
<script>
import * as HussarRouter from '@/utils/HussarRouter';
import * as flowAuth from '@/api/bpm/flowAuth';
/* @begin definitions # 页面局部定义 */
/* @end definitions */
export default {
  name: 'DfxtLrsj',
  components: {
    /* @begin components # 自定义组件 */
    /* @end components */
  },
  props: {
    /* @begin props # 自定义 */
    /* @end props */
  },
  data() {
    return {
      alreadyLoad: false, // 页面的alreadyLoad属性
      form_1FormCheck: {}, // 表单验证属性
      form_1FormData: {}, // 表单的data变量
      isFirstCreate: true, // 页面的isFirstCreate属性
      /* @begin data # 自定义数据属性 */
      /* @end data */
    };
  },
  computed: {
    /* @begin computed # 自定义计算属性 */
    /* @end computed */
  },
  watch: {
    /* @begin watch # 自定义侦听器 */
    /* @end watch */
  },
  methods: {
    /**
     * 表单加载
     */
    form_1FormLoad(callback, formId) {
      const self = this;
      // 表单未绑定数据模型或数据模型没有主键，该动作未成功生成
      if (callback && typeof callback === 'function') {
        callback();
      }
    },
    /**
     * 页面状态方法
     */
    hussar_0PageAllStateMe() {
      const self = this;
      if (self.hussar_0PageCommonStateMe) {
        self.hussar_0PageCommonStateMe();
      }
      if (self.hussar_0BpmStateHandler) {
        self.hussar_0BpmStateHandler();
      }
    },
    /**
     * 工作流表单权限方法
     */
    hussar_0PageRenderAllState(callBack) {
      const self = this;
      const failButContinue = true;
      flowAuth
        .getOnlineConfig()
        .then((res) => {
          if (res && res.msg === 'true') {
            // 权限查询条件
            if (self.$options.name && HussarRouter.query(self, 'processDefinitionKey')) {
              const condition = {
                formName: self.$options.name,
                taskId: HussarRouter.query(self, 'taskId'),
                processKey: HussarRouter.query(self, 'processDefinitionKey'),
                formType: HussarRouter.query(self, 'doneListIdentification'),
                taskDefinitionKey: HussarRouter.query(self, 'taskDefinitionKey'),
              };
              if (HussarRouter.query(self, 'doneListIdentification') === 3) {
                // 此处生成了空方法体
              }
              // 获取该工作流相应的表单权限配置
              if (flowAuth.getAllAuthConfigs) {
                flowAuth.getAllAuthConfigs(condition).then((res) => {
                  if (res && res.data && res.data.length > 0) {
                    // 循环权限配置，查到符合当前流程节点的权限
                    res.data.forEach((auth) => {
                      if (auth.taskDefinitionKey === HussarRouter.query(self, 'taskDefinitionKey')) {
                        // 获取禁用组件
                        if (auth.insDisabled) {
                          const insDisabled = JSON.parse(auth.insDisabled);
                          if (insDisabled && insDisabled.length > 0) {
                            insDisabled.forEach((ins) => {
                              const curIns = `${ins}Disabled`;
                              self[curIns] = true;
                            });
                          }
                        }
                        // 获取隐藏组件
                        if (auth.insHidden) {
                          const insHidden = JSON.parse(auth.insHidden);
                          if (insHidden && insHidden.length > 0) {
                            insHidden.forEach((ins) => {
                              const curIns = `${ins}Hidden`;
                              self[curIns] = true;
                            });
                          }
                        }
                        // 获取无需校验组件
                        if (auth.insNotCheck) {
                          const insNotCheck = JSON.parse(auth.insNotCheck);
                          if (insNotCheck && insNotCheck.length > 0) {
                            const formCheckParam = JSON.parse(auth.formCheckParam);
                            insNotCheck.forEach((ins) => {
                              if (formCheckParam[ins] && formCheckParam[ins].formKey) {
                                const formCheckData = `${formCheckParam[ins].formKey}FormCheck`;
                                if (formCheckParam[ins].field && self[formCheckData]) {
                                  self[formCheckData][formCheckParam[ins].field] = false;
                                }
                              }
                            });
                          }
                        }
                        // 获取隐藏插槽
                        if (auth.slotHidden) {
                          const colSlotHidden = JSON.parse(auth.slotHidden);
                          if (colSlotHidden && Object.keys(colSlotHidden).length > 0) {
                            const slotHiddenParam = `${Object.keys(colSlotHidden)}SlotHidden`;
                            self[slotHiddenParam] = Object.values(colSlotHidden);
                          }
                        }
                      }
                    });
                  }
                  self.alreadyLoad = true;
                });
              }
            } else {
              // 当前页面不是工作流表单
              self.alreadyLoad = true;
            }
          } else {
            self.alreadyLoad = true;
            if (callBack && typeof callBack === 'function') {
              callBack();
            }
          }
        })
        .catch(() => {
          self.$message.error('数据请求异常');
        });
    },
    /* @begin methods # 自定义方法 */
    /* @end methods */
  },
  created() {
    const self = this;
    // @begin created:before # 自定义创建钩子头部
    // @end created:before
    self.hussar_0PageRenderAllState();
    // @begin created:after # 自定义创建钩子尾部
    // @end created:after
  },
  mounted() {
    const self = this;
    // @begin mounted:before # 自定义挂载钩子头部
    // @end mounted:before
    if (self.$compilationMetadata.strategy) {
      window.curPageSelfFresh = function () {
        if (self.hussar_0Activated) {
          self.hussar_0Activated && self.hussar_0Activated();
        }
      };
    }
    // @begin mounted:after # 自定义挂载钩子尾部
    // @end mounted:after
  },
  filters: {},
  destroyed() {
    const self = this;
    // @begin destroyed:before # 自定义销毁钩子头部
    // @end destroyed:before
    // @begin destroyed:after # 自定义销毁钩子尾部
    // @end destroyed:after
  },
  activated() {
    const self = this;
    // @begin activated:before # 自定义组件激活钩子头部
    // @end activated:before
    // @begin activated:after # 自定义组件激活钩子尾部
    // @end activated:after
  },
  beforeRouteUpdate(to, from, next) {
    const self = this;
    next();
    if (to.query && to.query.systemParams && JSON.parse(to.query.systemParams).refresh === 1) {
      if (self.hussar_0Activated) {
        self.hussar_0Activated && self.hussar_0Activated();
      }
    }
  },
  deactivated() {
    const self = this;
    // @begin deactivated:before # 自定义组件失活钩子头部
    // @end deactivated:before
    // @begin deactivated:after # 自定义组件失活钩子尾部
    // @end deactivated:after
  },
  /* @begin options # 自定义页面组件创建选项 */
  /* @end options */
};
</script>
<!-- @begin style:before # 自定义 style 代码块（较低优先级） -->
<!-- @end style:before -->
<style scoped>
/*公共，用于固定*/
.lcdp_axe_main {
  height: 100%;
  overflow: auto;
  transform: scale(1);
}
/*公共，用于设置文字提示的最大宽度*/
.el-tooltip__popper {
  max-width: 500px;
}
.DfxtLrsj.hussar_0 {
  position: relative;
  top: 0;
  left: 0;
  display: block;
  width: calc(100% - 0px - 0px);
  height: 100%;
}
.lcdp_axe.DfxtLrsj .form_1 {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
}
.jxd_hyperlinks_span {
  color: rgb(58, 142, 230);
  cursor: pointer;
}
</style>
<style></style>
<!-- @begin style:after # 自定义 style 代码块（较高优先级） -->
<!-- @end style:after -->
